package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;

public class CollectionDemo2 {
    public static void main(String[] args) {
//        Collection c = new HashSet();
        Collection c = new ArrayList();
        c.add(new Point(1,2));
        c.add(new Point(3,4));
        c.add(new Point(5,6));
        c.add(new Point(7,8));
        c.add(new Point(9,0));

        boolean b = c.add(new Point(1,2));
        System.out.println(b);//false HashSet看的是equalse 内容相同 则为不能添加
        //[元素1.toString,元素2.toString,...]
        System.out.println(c);

        //boolean contains(Object o)
        //判断当前集合是否包含给定元素o,若包含则返回true
        //判断依据的是 给定元素在当前集合是否存在equals()为true的情况
        Point p = new Point(1, 2);
        boolean contain = c.contains(p);
        System.out.println(contain);//true

        //boolean remove(Object o)---一般都不接收boolean结果
        //若存在相同元素则只删除第一次匹配的元素
        boolean remove = c.remove(p);
        System.out.println(remove);
        System.out.println(c);
    }
}
